<!DOCTYPE html>
<html lang="en" style="overflow:hidden">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>viewer</title>
</head>
<body>
<!--<button onclick="switchScene()">切换场景</button>-->
<canvas id="container" width="1366" height="662">
    Your browser doesn't appear to support the HTML5 <code>&lt;canvas&gt;</code> element.
</canvas>

<script src="lib/three.js" type="text/javascript"></script>
<script src="lib/Detector.js" type="text/javascript"></script>
<script src="lib/moment.min.js" type="text/javascript"></script>
<script src="lib/stats.min.js" type="text/javascript"></script>
<script src="lib/json.js" type="text/javascript"></script>
<script src="lib/webtoolkit.base64.js" type="text/javascript"></script>
<script src="lib/modernizr.js" type="text/javascript"></script>
<script src="lib/ace/src-min-noconflict/ace.js" type="text/javascript"></script>

<script src="lib/jquery/js/jquery-1.9.1.min.js" type="text/javascript"></script>
<script src="lib/jquery/js/jquery-ui-1.10.2.custom.min.js" type="text/javascript"></script>
<script src="lib/THREEx.screenshot.js" type="text/javascript"></script>
<script src="lib/THREEx.FullScreen.js" type="text/javascript"></script>
<script src="lib/THREEx.WindowResize.js" type="text/javascript"></script>

<script src="GlobalConfig.js"></script>
<script src="postprocessing.js" type="text/javascript"></script>
<script src="unrealbloompass.js" type="text/javascript"></script>
<script src="shaders.js" type="text/javascript"></script>
<script src="globescene.js" type="text/javascript"></script>
<script src="planescene.js" type="text/javascript"></script>
<script src="localscene.js" type="text/javascript"></script>
<script src="monitorscene.js" type="text/javascript"></script>
<script src="scenecontrols.js" type="text/javascript"></script>
<script src="visualizeline.js" type="text/javascript"></script>
<script src="meshline.js" type="text/javascript"></script>
<script src="sceneswitcher.js" type="text/javascript"></script>
<script src="./js/controls/OrbitControls.js"></script>
<script src="./js/loaders/STLLoader.js"></script>
<script src="renderobject.js"></script>
<script src="./assets/earth/earthLines.js"></script>
<script src="./assets/earth/earthStationChina.js"></script>
<script src="./assets/earth/starConection.js"></script>
<script src="./assets/earth/earthStation.js"></script>

<script>
<!-- 0 星座 1星间 2星地 -->
</script>
<script>
	var strScene=window.location.href; //取得整个地址栏
	var num=strScene.indexOf("?")
	var str=strScene.substr(num+1);
	strScene = str.substr(0,1);
	var RenderType = Number(str.substr(str.indexOf(",")+1))
	console.log(strScene,RenderType);

    strScene = 4;
    RenderType = 0;

    var domElement = document.getElementById("container");
    domElement.width = window.innerWidth;
    domElement.height = window.innerHeight;

    var sceneReadyCallback = function() {
    };
    var resourceLoadingStart = function(url) {
    };
    var resourceLoadingFinish = function(successful, remainingResources) {
    };
    var webGlErrorCallback = function(ex) {
    };
    var animationStoppedCallback = function() {
    };
    var contextLostCallback = function(event) {
    };
    var sceneCallbacks = {
        sceneReadyCallback : sceneReadyCallback,
        resourceLoadingStart : resourceLoadingStart,
        resourceLoadingFinish : resourceLoadingFinish,
        webGlErrorCallback : webGlErrorCallback,
        animationStoppedCallback : animationStoppedCallback,
        contextLostCallback : contextLostCallback
    };

    var switchSceneIndex = 0;
    var sceneSwitch = new KMG.SceneSwitch();
    function switchScene(){
        sceneSwitch.switch(switchSceneIndex % 3);
        switchSceneIndex++;
    }

    var renderer = new THREE.WebGLRenderer( { canvas : domElement,antialias: true} );
    renderer.setSize( window.innerWidth, window.innerHeight );
    renderer.gammaInput = true;
    renderer.gammaOutput = true;
    renderer.physicallyBasedShading = true;
    renderer.autoClear = false;
    renderer.autoClearColor = true;
    renderer.autoClearDepth = true;
    renderer.autoClearStencil = true;
    renderer.setClearColor( 0x000000, 1.0 );

    var config = KMG.Util.extend({}, KMG.DefaultConfig);
    config.textureResolution = "2048x1024";
    config.camera.near = 2;
    config.renderer = renderer;
	
    var globeScene = null;
    var planeScene = null;
    var localScene = null;
    var monitorScene = null;
	if (strScene == 0) {
		globeScene = new KMG.GlobeScene(domElement, config, sceneCallbacks, null, null);
		globeScene.start();
	} else if (strScene == 1) {
		planeScene = new KMG.PlaneScene(domElement, config);
		planeScene.start();
	} else if (strScene == 2) {
		localScene = new KMG.LocalScene(domElement, config);
		localScene.start();
	} else if (strScene == 4) {
        monitorScene = new KMG.MonitorScene(domElement, config);
        monitorScene.start();
    }

    //sceneSwitch.add(globeScene);
    //sceneSwitch.add(planeScene);
    //sceneSwitch.add(localScene);
    //switchScene();

    function onWindowResize() {
		if (globeScene != null) {
			globeScene.onSize();
		}
		if (planeScene != null) {
			planeScene.onSize();
		}
		if (localScene != null) {
			localScene.onSize();
		}
        if (monitorScene != null) {
            monitorScene.onSize();
        }
    }
    window.addEventListener( 'resize', onWindowResize, false );

    function animate() {
        requestAnimationFrame(animate);

		if (globeScene != null) {
			globeScene.onRender();
		}
		if (planeScene != null) {
			planeScene.onRender();
		}
		if (localScene != null) {
			localScene.onRender();
		}
        if (monitorScene != null) {
            monitorScene.onRender();
        }
    }
    onWindowResize();
	
    animate();
	
</script>

</body>
</html>
